
# R 语言 饼图 pie( x, labels,radius,main,col,clockwise);

# x 包含饼图中使用的数值的向量
# labels 用于给出切片的描述
# radius 表示饼图园的半径(-1~+1)
# main 饼图的标题
# col 调色板
# clockwise 片段是顺时针还是逆时针的逻辑值

x <- c(21,62,10,53);
labels <- c("London","New York","Singapore","Mumbia");

png(file="city.jpg");

pie(x,labels);

dev.off();

# 饼图的标题和颜色
png(file="city_tile_colours.png");

pie(x,labels,main="City pie chart",col=rainbow(length(x)));
print( rainbow( length(x)))
dev.off();

# 切片百分比和图标比列
# Create data for the graph.
x <-  c(21, 62, 10,53)
labels <-  c("London","New York","Singapore","Mumbai")

piepercent<- round(100*x/sum(x), 1)

print( piepercent )

# Give the chart file a name.
png(file = "city_percentage_legends.jpg")

# Plot the chart.
pie(x, labels = piepercent, main = "City pie chart",col = rainbow(length(x)))
legend("topright", c("London","New York","Singapore","Mumbai"), cex = 0.8,
       fill = rainbow(length(x)))

# Save the file.
dev.off()

# 3D 饼图
library(plotrix);

png(file="3d_pie_chart.jpg");
pie3D(x,labels=labels,explode=0.1,main="Pie Chart of Coutries");
dev.off();



